package com.example.service.impl;

import com.example.dao.OrderDao;
import com.example.entity.Order;
import com.example.service.OrderService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class OrderServiceImpl implements OrderService {

    @Autowired
    private OrderDao orderDao;

    @Override
    public boolean createOrder(Order order) {
        return orderDao.insertOrder(order) > 0;
    }

    @Override
    public Order getOrderById(Integer order_id) {
        return orderDao.getOrderById(order_id);
    }

    @Override
    public List<Order> getOrdersByRequesterId(Integer requesterId) {
        return orderDao.getOrdersByRequesterId(requesterId);
    }

    @Override
    public List<Order> getOrdersByProviderId(Integer providerId) {
        return orderDao.getOrdersByProviderId(providerId);
    }

    @Override
    public List<Order> getAllOrders() {
        return orderDao.getAllOrders();
    }
}